﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace InnovTech.Data.Proxy
{
    /// <summary>
    /// Describes a proxy for a object.
    /// </summary>
    public class ObjectProxy : ProxyBase, IObjectProxy
    {

        protected Dictionary<string, IObjectMemberProxy> _members;

        public ObjectProxy(string name, Type type)
            : base(name, type)
        {
            _members = new Dictionary<string, IObjectMemberProxy>();
        }

       
        /// <summary>
        /// Gets the members of the object.
        /// </summary>
        public IEnumerable<IObjectMemberProxy> Members
        {
            get { return _members.Values; }
        }

        /// <summary>
        /// Gets or sets a member with name.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public IObjectMemberProxy this[string name]
        {
            get
            {
                return _members[name];
            }
            set
            {
                _members[name] = value;
            }
        }

        /// <summary>
        /// Checks wether this object contains a member with the given name.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public bool ContainsMember(string name)
        {
            return _members.ContainsKey(name);
        }
    }
}
